﻿using System.Runtime.Serialization;
using TripLOA.WebService.Exceptions;

namespace TripLOA.WebService.Serializable
{
    /// <summary>
    /// Abstract class that represents a generic WebService response
    /// </summary>
    [DataContract]
    public abstract class WSObject
    {
        private string status;
        
        #region Properties
        /// <summary>
        /// Request status, accepted values are "ok" or "fail"
        /// </summary>
        [DataMember]
        public string Status {
            get { return status; }
            set
            {
                if (value != "ok" && value != "fail")
                {
                    //TODO Throw an exception
                    status = "fail";
                    throw new InvalidStatusException();
                }
                else
                {
                    status = value;
                }
            }
        }

        /// <summary>
        /// A generic message sent to the client. Can be null
        /// </summary>
        [DataMember]
        public string Message { get; set; }

        /// <summary>
        /// Server Cache ID
        /// </summary>
        [DataMember]
        public string CacheID { get; set; }
        #endregion
    }
}
